/*
 * 项目名称:platform-plus
 * 类名称:SysJmCourseController.java
 * 包名称:com.platform.modules.sys.controller
 *
 * 修改履历:
 *     日期                       修正者        主要内容
 *     2021-06-28 21:48:50        klwu     初版做成
 *
 * Copyright (c) 2019-2019 微同软件
 */
package com.platform.modules.sys.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.platform.common.annotation.SysLog;
import com.platform.common.utils.RestResponse;
import com.platform.modules.sys.entity.SysJmCourseEntity;
import com.platform.modules.sys.service.SysJmCourseService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * 课程任务表Controller
 *
 * @author klwu
 * @date 2021-06-28 21:48:50
 */
@RestController
@RequestMapping("sys/jmcourse")
public class SysJmCourseController extends AbstractController {
    @Autowired
    private SysJmCourseService sysJmCourseService;

    /**
     * 查看所有列表
     *
     * @param params 查询参数
     * @return RestResponse
     */
    @RequestMapping("/queryAll")
    @RequiresPermissions("sys:jmcourse:list")
    public RestResponse queryAll(@RequestParam Map<String, Object> params) {
        List<SysJmCourseEntity> list = sysJmCourseService.queryAll(params);

        return RestResponse.success().put("list", list);
    }

    /**
     * 分页查询课程任务表
     *
     * @param params 查询参数
     * @return RestResponse
     */
    @GetMapping("/list")
    @RequiresPermissions("sys:jmcourse:list")
    public RestResponse list(@RequestParam Map<String, Object> params) {
        Page page = sysJmCourseService.queryPage(params);
        return RestResponse.success().put("page", page);
    }

    /**
     * 根据主键查询详情
     *
     * @param id 主键
     * @return RestResponse
     */
    @RequestMapping("/info/{id}")
    @RequiresPermissions("sys:jmcourse:info")
    public RestResponse info(@PathVariable("id") String id) {
        SysJmCourseEntity sysJmCourse = sysJmCourseService.getById(id);

        return RestResponse.success().put("jmcourse", sysJmCourse);
    }

    /**
     * 新增课程任务表
     *
     * @param sysJmCourse sysJmCourse
     * @return RestResponse
     */
    @SysLog("新增课程任务表")
    @RequestMapping("/save")
    @RequiresPermissions("sys:jmcourse:save")
    public RestResponse save(@RequestBody SysJmCourseEntity sysJmCourse) {
        sysJmCourse.setCourseLess(sysJmCourse.getCoursePersions());
        sysJmCourseService.add(sysJmCourse);

        return RestResponse.success();
    }

    /**
     * 修改课程任务表
     *
     * @param sysJmCourse sysJmCourse
     * @return RestResponse
     */
    @SysLog("修改课程任务表")
    @RequestMapping("/update")
    @RequiresPermissions("sys:jmcourse:update")
    public RestResponse update(@RequestBody SysJmCourseEntity sysJmCourse) {

        sysJmCourseService.update(sysJmCourse);

        return RestResponse.success();
    }

    /**
     * 根据主键删除课程任务表
     *
     * @param ids ids
     * @return RestResponse
     */
    @SysLog("删除课程任务表")
    @RequestMapping("/delete")
    @RequiresPermissions("sys:jmcourse:delete")
    public RestResponse delete(@RequestBody String[] ids) {
        sysJmCourseService.deleteBatch(ids);

        return RestResponse.success();
    }
}
